{\rtf1\ansi\ansicpg1252\cocoartf1265
{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
{\colortbl;\red255\green255\blue255;}
\margl1440\margr1440\vieww18440\viewh17900\viewkind0
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural

\f0\fs36 \cf0 // Global variable declarations and initialization\
Semaphore wrapped = 0;\
Semaphore labeled = 0;\
Semaphore max-wrapper-1 = 1;\
Semaphore max-chocolate-2 = 1;\
Semaphore max-wrapped3 = 1;\
Semaphore max-labeled4 = 1;\
\
void robot1_thread()\
\{\
	while(true)\
	\{\
		max-wrapper-1.down();\
		retrieve_wrapper();\
		holding-wrapper-1.up();\
	\}\
\}\
\
void robot2_thread()\
\{\
	while(true)\
	\{\
		max-chocolate-2.down();\
		retrieved_bar()\
		holding-chocolate-2.up();\
	\}\
\}\
\
void robot3_thread()\
\{\
	while(true)\
	\{\
		holding-chocolate-2.down();\
		take_bar();\
\
		holding-wrapper-1.down();\
		take_wrapper();\
		\
		fold_wrapper();\
		wrapped.up();\
	\}\
\}\
\
void robot4_thread()\
\{\
	while(true)\
	\{\
		wrapped.down();\
		take_wrapped_bar();\
		max-chocolate-2.up\
		max-wrapper-1.up\
\
		label_bar();\
		labeled.up();\
	\}\
\}\
\
void robot5_thread()\
\{\
	while(true)\
	\{\
		labeled.down();\
		take_labeled_bar();\
\
		place_bar_in_box();\
\
	\}\
\}\
\
\
\
\
\
}